<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1,maximum-scale=1, user-scalable=no"/>
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link href="#(contextPath)/task_template/common/css/index.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="#(contextPath)/assets/front/web/css/layer.css?#(getUUID())" />
		<title>#(task.task_title??'')</title>
	</head>
	
	<body >
		<div id="commentModal" style="margin:.25rem">
			<div style="min-height:.98rem;height:auto;width:100%;background:#fff;"  class="inp">
				<div style="text-align:center">
					<span id="result" style="color:red;">&#12288;</span>
				</div>
				<div>
					<input type="text" id="cInput" class="oInput" name="" flag="nohave" style="padding-left:.3rem;min-height:.64rem;height:auto;width:90%;background:#f7f7fa;border-radius:10px;margin-left:.28rem;margin-top:.17rem;" placeholder="我也来说一句" toName="">
				</div>
				<!-- <em class="fabu" style="color:#cfcfcf;font-size:.28rem;margin-left:.2rem;">发布</em> -->
				<div style="display:inline-flex;width:100%;justify-content:center">
					<div style="background-color:red;border-radius:.1rem;padding:.2rem;margin:.1rem" id="saveBtn">
						<div style="color:white;text-align:center" class="fabu" >保存</div>
					</div>
					<div style="background-color:#d5d5d5;border-radius:.1rem;padding:.2rem;margin:.1rem" id="closeBtn">
						<div style="color:white;text-align:center" >关闭</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="#(contextPath)/task_template/common/js/jquery.min.js" ></script>
		<script type="text/javascript" src="#(contextPath)/task_template/common/js/common.js" ></script>
		<script type="text/javascript" src="#(contextPath)/assets/front/web/script/layer.js"></script>
		<script>
			$("#closeBtn").click(function(){
				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
			});
			$("#saveBtn").click(function(){
				var comments= $("#cInput").val();
				if($("#cInput").val()===""){
					$("#result").html("请输入评论内容")
					return;
				}
				var parent = window.parent.document;
				$.ajax({
                    url: "/platform/mission/saveComment",
                    type: "POST",
                    data:{
                   	 'comments':comments,
                   	 "fromUserNickName":localStorage.getItem('name'),
                   	 "fromUserUrl":localStorage.getItem('imgUrl'),
                   	 "toUserNickName":$("#toUserNickName",parent).val(),
                   	 "toUserUrl":$("#toUserUrl",parent).val(),
                   	 "taskId":$("#id",parent).val(),
                   	 "ucode":$("#ucode",parent).val(),
                   },
                    success: function(res) {
                         var  data=res;
                         if(data.result){
                       		//请求成功后
                             var name=localStorage.getItem('name');
                             var imgUrl=localStorage.getItem('imgUrl');
                             var toName=$('.oInput').attr('toName')
                             var commBoxHtml="<div class='commBox'>";
                             commBoxHtml+="<div class='namePic'><img src='"+imgUrl+"' class='userUrl'><em class='userName'>"+name+"</em></div>"
                             if($('.oInput').attr('flag')=='nohave'){
                                   commBoxHtml+='<div class="toBox"><div class="comcon">'+comments+'</div></div><div class="bai"></div>'  
                             }else if($('.oInput').attr('flag')=='have'){
                                 commBoxHtml+='<div class="toBox"><div class="comcon">回复<em class="toName">'+toName+'</em>:<em style="margin-left:.2rem">'+comments+'</em></div></div><div class="bai"></div>'
                             }
                             commBoxHtml+="</div>";
                             var zpl=$('.zpl',parent).html();
                             $('.zpl',parent).html(parseInt(zpl)+1);
                             $(".afterBox",parent).after(commBoxHtml)
                             $('.oInput',parent).val('')
                             $('.oInput',parent).attr('placeholder','我也来说一句');
                             $('#closeBtn').trigger('click')
                         }else{
                        	 $("#result").html(data.msg)
                         }
                   }
               });
			})
		</script>
		</body>
</html>

